﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model.enumer;

namespace com.lover.astd.common.logicexe.activities
{
    public class GiftEventExe : ExeBase
    {
        public GiftEventExe() { _name = ConfigStrings.S_GiftEvent; _readable = ConfigStrings.SR_GiftEvent; }
        public override long execute()
        {
            if (!_user.isActivityRunning(ActivityType.GiftEvent)) return next_hour();
            Dictionary<string, string> conf = getConfig();
            if (!conf.ContainsKey(ConfigStrings.enabled) || !conf[ConfigStrings.enabled].ToLower().Equals("true")) return an_hour_later();
            string serial = "231";
            if (conf.ContainsKey(ConfigStrings.serial))
            {
                serial = conf[ConfigStrings.serial];
                if (serial == null || serial.Trim() == "") serial = "231";
            }
            ActivityMgr mgr = ServiceFactory.getActivityManager();

            int result = mgr.handleGiftEventInfo(_proto, _logger, serial);
            if (result == 10) return next_day();
            if (result == 1) return next_hour();
            else return next_hour();
        }
    }
}
